package com.motion.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.motion.generator.entity.UserArticle;
import com.motion.generator.mapper.UserArticleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserArticleService {
    @Autowired
    private UserArticleMapper userArticleMapper;
    public boolean userifCollect(Long useId,Long ArticleId){
        if(userArticleMapper.selectOne(new QueryWrapper<UserArticle>().eq("userId",useId).eq("articleId",ArticleId))!=null){
            return true;
        }else
            return false;
    }
    public UserArticle insert(UserArticle userArticle){
        userArticleMapper.insert(userArticle);
        return userArticle;
    }
    public UserArticle delect(Long articleId){
        UserArticle ref=userArticleMapper.selectById(articleId);
        userArticleMapper.deleteById(articleId);
        return ref;
    }
}
